<template>
	<view>
		<view class="main">
			<view class="messageAll">
				<view class="message">
				    <view class="real-name">真实姓名</view>
					<input placeholder="请填写你的真实姓名" v-model="info.name"/>
					<view class="blank"></view>
					<view class="real-name" style="margin-top: 50rpx;">身份证号</view>
					<input placeholder="请填写你的身份证号码" maxlength="18"  type="idcard" v-model="info.id_card" />
					<view class="blank"></view>
				</view>
				
			</view>
			<view class="apply">申请认证</view>
			<view class="apply-list">
				<view class="apply-text">· 身份信息仅作为用户身份验证，绝不会外泄或用作其他用途。</view>
				<view class="apply-text">· 填写身份证一 致的本人真实姓名及证件号码。</view>
				<view class="apply-text">· 认证成功后信息无法更改。</view>
			</view>
			<view v-if="info.is_examine==2&&info.id_card.length==18" class="activeCommit commit" @click="submit"><span class="commit-text">同意协议并提交认证</span></view>
			<view v-else-if="info.is_examine==0" class='commit'><span class="commit-text">审核中</span></view>
			<view v-else-if="info.is_examine==1" class='commit'><span class="commit-text">认证成功</span></view>
			<view class="deal">继续表示已了解并同意<span class="deal-text" @click="toXieyi">《用户协议》</span>及<span class="deal-text" @click="toYinsi">《隐私协议》</span></view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				info:{},
				cantijiao:true
			}
		},
		onShow() {
			this.getData()
		},
		methods:{
			getData(){
				let that = this
				this.$utils.request("/api/useridcard/index", {
				}, function (res) {
				   if(res.code==200){
					   // console.log('res',res)
					  // that.list = res.data
					  if(res.data.constructor === Array){
						  that.info={
							  name:'',
							  id_card:'',
							  is_examine:2
						  }
					  }else{
						  that.info=res.data
					  }
					  if(that.info.id_card.length==18){
						  that.cantijiao=false
					  }
					}
				})
			},
			toXieyi(){
				uni.navigateTo({
					url:'/pages/my/xieyi'
				})
			},
			submit(){
				if(this.cantijiao&&this.info.name&&this.info.id_card.length==18){
					let that = this
					this.$utils.postrequest("/api/useridcard/edit", that.info, function (res) {
					   if(res.code==200){
						   that.$utils.showLayer('保存成功')
						   that.getData()
						}
					})
				}
			},
			toYinsi(){
				uni.navigateTo({
					url: '/pages/login/policy'
				})
			}
		}
	}
</script>

<style>
	page{
		background: #F5F5F7;
		height: 1600rpx;
	}
	.main{
		margin: 22rpx 0rpx 0rpx 25rpx;
	}
	.messageAll{
		width: 705rpx;
		height: 443rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
	}
	.message{
		margin:53rpx 0rpx 0rpx 44rpx;
		display: inline-block;
	}
	.real-name{
		
		font-size: 26rpx;
		font-family: PingFang SC;
		
		color: #32303F;
		line-height: 30rpx;
	}
	input{
		margin-top: 50rpx;
		font-size: 26rpx;
		
		font-family: PingFang SC;
		
		color: #9A97A5;
		line-height: 30px;
	}
	.blank{
		width: 617rpx;
		height: 2rpx;
		background: #EAEAEA;
		margin-top: 26rpx;
	}
	.apply{
		margin: 40rpx 0rpx 0rpx 20rpx;
		font-size: 24rpx;
		font-family: PingFang SC;
		
		color: #9A97A5;
		line-height: 30rpx;
	}
	.apply-text{
		font-size: 24rpx;
		font-family: PingFang SC;
		
		color: #747A86;
		line-height: 38rpx;
	}
	.apply-list{
		margin: 20rpx 0rpx 0rpx 20rpx;
	}
	.commit{
		text-align: center;
		height: 105rpx;
		line-height: 105rpx;
		background: #D1CFDD;
		border-radius: 53rpx;
		font-size: 24rpx;
		font-family: PingFang SC;
		
		color: #FFFFFF;
		margin-right: 30rpx;
		margin-top: 120rpx;
	}
	.activeCommit{
		background-color: #6C51FF;
		
	}
	.deal{
		margin: 58rpx 0rpx 0rpx 48rpx;
		font-size: 24rpx;
		font-family: PingFang SC;
		
		color: #A9A7B4;
		line-height: 30rpx;
	}
	.deal-text{
		font-size: 24rpx;
		font-family: PingFang SC;
		
		color: #573AF6;
		line-height: 30rpx;
	}
</style>
